//
//  Asteroid.m
//  AsteroidGame
//
//  Created by iD Student on 7/11/13.
//  Copyright (c) 2013 iD Student. All rights reserved.
//

#import "Asteroid.h"

@implementation Asteroid
{
    int rotation;
}
@synthesize imageView;

- (id) initWithRandomValueX:(int)x withY:(int)y
{
    int radius = arc4random() % 70 + 10;
    float randomX = arc4random() % (x - radius/2) + radius/2.0;
    int randomY = arc4random() % (y - radius/2) + radius/2;
    imageView = [[UIImageView alloc]initWithFrame:CGRectMake(randomX, randomY, radius, radius)];
    imageView.center = CGPointMake(randomX, (-1.0) * (imageView.frame.size.height/2.0));
    imageView.image = [UIImage imageNamed:@"asteroid.png"];
    rotation = arc4random() % 360 + 1;
    [imageView setTransform:CGAffineTransformMakeRotation(rotation)];
    return self;
}

- (void) updateWithVelocityX:(int)velocityX withVelocityY:(int)velocityY
{
    imageView.center = CGPointMake(imageView.center.x + velocityX, imageView.center.y + velocityY);
}

@end
